﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Xml;

namespace FreeAccessNetdisk.src.classes
{
    public class ObsConfig
    {
        public string AccessKey { get; set; }
        public string SecretKey { get;  set; }
        public string Endpoint { get;  set; }


        public ObsConfig()
        {
            // 为保OBS安全，密钥作者分配，写入环境变量
            AccessKey = Environment.GetEnvironmentVariable("AccessKeyID");
            SecretKey = Environment.GetEnvironmentVariable("SecretAccessKey");
            Endpoint = "obs.cn-south-1.myhuaweicloud.com";
        }


        /*
        public ObsConfig(string accessKey, string secretKey, string endpoint)
        {
            AccessKey = accessKey;
            SecretKey = secretKey;
            Endpoint = endpoint;
        }

        public static ObsConfig LoadFromConfig(string configFilePath)
        {
            // Implement logic to load the configuration from a file
            // For example, you can use a JSON or XML file to store the configuration
            // Here's a simple example with JSON

            string json = File.ReadAllText(configFilePath);
            var configData = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

            if (configData.ContainsKey("AccessKey") &&
                configData.ContainsKey("SecretKey") &&
                configData.ContainsKey("Endpoint"))
            {
                return new ObsConfig(
                    configData["AccessKey"],
                    configData["SecretKey"],
                    configData["Endpoint"]);
            }

            throw new Exception("Invalid configuration file");
        }
        */


    }
}
